package com.examination.mlib.dialog.commondialog;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.examination.mlib.R;
import com.yilijk.base.basedialog.BaseDialog;
import com.yilijk.base.basedialog.DialogChain;
import com.yilijk.base.utils.ClickUtils;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2022/01/19
 */
public class PromptDialog extends BaseDialog implements View.OnClickListener {




    public PromptDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_prompt);
    }


    @Override
    public void onClick(View v) {

    }

    @Override
    public void intercept(@NonNull DialogChain chain) {
        if (chain!=null){
            super.intercept(chain);
        }
    }

    public PromptDialog setTitle(String t){
        if (!TextUtils.isEmpty(t)){
            ((TextView)findViewById(R.id.prompt_title)).setText(t);
        }else{
            ((TextView)findViewById(R.id.prompt_title)).setText("提示");
        }
        return this;
    }

    public PromptDialog setContent(String c){
        if (!TextUtils.isEmpty(c)){
            ((TextView)findViewById(R.id.prompt_txt)).setText(c);
        }else{
            findViewById(R.id.prompt_txt).setVisibility(View.GONE);
        }
        return this;
    }

    public PromptDialog setBt(String b1,String b2,View.OnClickListener l1, View.OnClickListener l2){
        if (!TextUtils.isEmpty(b1)){
            findViewById(R.id.prompt_bt1_txt).setVisibility(View.VISIBLE);
            ((TextView)findViewById(R.id.prompt_bt1_txt)).setText(b1);
            ClickUtils.setFastOnClickListener(findViewById(R.id.prompt_bt1_txt),l1);
        }else{
            findViewById(R.id.prompt_bt1_txt).setVisibility(View.GONE);
        }

        if (!TextUtils.isEmpty(b2)){
            findViewById(R.id.prompt_bt2).setVisibility(View.VISIBLE);
            ((TextView)findViewById(R.id.prompt_bt2_txt)).setText(b2);
            ClickUtils.setFastOnClickListener(findViewById(R.id.prompt_bt2),l2);
        }else{
            findViewById(R.id.prompt_bt2).setVisibility(View.GONE);
        }
        return this;
    }

}
